<template>
  <div>
    <el-form v-model="transportTripsForm" label-width="80px">
      <el-form-item label="线路名称:">
        <el-select v-model="transportTripsForm.transportLineId" placeholder="请选择">
          <el-option label="请选择" value=""/>
          <el-option v-for="(item,index) in transportLineData" :label="item.name" :value="item.id" :key="index"/>
        </el-select>
      </el-form-item>

      <el-form-item label="车次名称:">
        <el-input v-model="transportTripsForm.name" placeholder="请输入车次名称"/>
      </el-form-item>
      <el-form-item label="发车时间:">
        <el-time-select
          v-model="transportTripsForm.departureTime"
          :picker-options="{
    start: '00:00',
    step: '00:30',
    end: '23:30'
  }"
          placeholder="选择时间"
        >
        </el-time-select>
      </el-form-item>

      <el-form-item label="发车周期:">
        <el-select v-model="transportTripsForm.period" placeholder="请选择">
          <el-option label="请选择" value=""/>
          <el-option label="天" value="1"/>
          <el-option label="周" value="2"/>
          <el-option label="月" value="3"/>
        </el-select>
      </el-form-item>

      <el-form-item label="状态:">
        <el-radio v-model="transportTripsForm.status" :label="1" border>正常</el-radio>
        <el-radio v-model="transportTripsForm.status" :label="0" border>禁用</el-radio>
      </el-form-item>

      <el-form-item label="操作:">
        <el-button type="primary" @click="addTransportTrips">添加</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import transportLine from '@/api/base/transportLine/index'
import transportTrips from '@/api/base/transportTrips/index'

export default {
  name: 'add',
  data() {
    return {
      transportLineData: [],
      transportTripsForm: {
        name: '',
        departureTime: '',
        transportLineId: '',
        period: '',
        status: 1
      }
    }
  }, methods: {
    addTransportTrips() {
      transportTrips.addTransportTrips(this.transportTripsForm).then(data => {
        this.$message({
          type: 'success',
          showClose: true,
          message: '车次添加成功!'
        })
        this.$router.push({ path: '/transport-trips-index' })
      })
    },
    getAllTransportLine() {
      transportLine.getAllTransportLine().then(data => {
        this.transportLineData = data.data
      })
    }
  }, mounted() {
    this.getAllTransportLine()
  }
}
</script>

<style scoped>

</style>
